<!DOCTYPE html  >
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


<head th:include="/base/common_css('test')">


<body>
<div th:include="/base/common_banner"></div>

<!-- Header ends -->
<!-- Main content starts -->

<div class="content">

    <!-- Sidebar -->
    <!--menu ????-->
    <div th:include="/base/common_menu"></div>
    <!--menu????-->
    <!-- Sidebar ends -->

    <!-- Main bar -->
    <div class="mainbar">

        <!-- Page heading -->
        <div th:include="/base/common_pageHeader"></div>
        <!-- Page heading ends -->

        <div class="matter">
            <div class="container">
                <div class="row">
                    <div class="col-md-10">
                        <div class="widget">
                            <div class="widget-head">
                                <div class="pull-left">分类列表</div>
                                <div class="widget-icons pull-right">

                                    <div class="btn-group">
                                    </div>
                                </div>
                                <div class="clearfix"></div>
                            </div>

                            <div class="widget-content medias">
                                <table border="1" class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>

                                        <th>订单编号</th>
                                        <th>创建时间</th>
                                        <th>订单类型</th>
                                        <th>订单状态</th>
                                        <th>操作</th>
                                    </tr>
                                    <!--<tbody >-->

                                    <tr th:each="obj,objStat:${ordersList.list}">
                                        <td th:text="${obj.orderNo}">123</td>
                                        <td th:text="${obj.createTime}">123</td>
                                        <td th:text="${obj.orderType}">123</td>
                                        <td th:text="${obj.status}? '有效':'失效'">123</td>
                                        <td>
                                            <button type="button" class="btn btn-default btn-xs"
                                                    data-toggle="modal" data-target="#myModal" data-backdrop="static">
                                                <i
                                                        class="glyphicon glyphicon-repeat"
                                                        th:onclick="'javascript:updateOrder(\''+${obj.orderNo}+'\');'"
                                                >修改</i></button>
                                        </td>
                                    </tr>
                                    </thead>
                                </table>
                                <!--分页-->
                                <div class="widget-foot">
                                    <div id="page1">
                                        <input type="hidden" id="pageNumber" th:value="${ordersList.pageNum}">
                                        <input type="hidden" id="pageSize" th:value="${ordersList.pageSize}">
                                        <input type="hidden" id="totalPage" th:value="${ordersList.pages}">
                                        <input type="hidden" id="total" th:value="${ordersList.total}">
                                    </div>
                                </div>

                                <!-- Mainbar ends -->
                                <div class="clearfix"></div>

                                <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
                                     aria-labelledby="myModalLabel">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal"
                                                        aria-label="Close"><span aria-hidden="true">&times;</span>
                                                </button>
                                                <h4 class="modal-title" id="myModalLabel">修改</h4>
                                            </div>

                                            <form class="form-horizontal" role="form" action="#" method="post">

                                                <div class="modal-body">
                                                    <form action="#" method="post"
                                                          enctype="multipart/form-data">
                                                        <input class="col-lg-4 form-control " type="hidden" id="orderNo"
                                                               th:value="${orderNo}">
                                                        <div class="form-group">
                                                            <label class="col-lg-4 control-label">订单状态</label>
                                                            <div class="col-lg-8">
                                                                <select id="status" th:value="${status}"
                                                                        class="form-control" >
                                                                    <option value="1">有效</option>
                                                                    <option value="0">无效</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </form>
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-default"
                                                                data-dismiss="modal"
                                                                onclick="cancle()">取消
                                                        </button>
                                                        <button type="button" id="saveOrders" class="btn btn-primary"
                                                                data-dismiss="modal"><span
                                                                class="glyphicon glyphicon-floppy-disk"
                                                                aria-hidden="true"></span>保存
                                                            <!--onclick ="javascript:addSave();-->
                                                        </button>
                                                    </div>
                                                </div>

                                        </div>
                                    </div>


                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>


    </div>
</div>

<!--footer-->
<div th:include="/base/common_footer"></div>
<!---->


<!-- Scroll to top -->
<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span>

<!--js????-->
<div th:include="/base/common_js"></div>
<!--js????-->

<!-- Script for this page -->

<script type="text/javascript">
    initPage('page1', '/view/order', {}, false);
    function cancle() {
        window.location = "/view/order?pageNumber=1&&pageSize=10"
    }




    //修改查询
    function updateOrder(orderNo) {
        $.ajax({
            url: "/view/getOrderNo",
            data: {
                'orderNo': orderNo,
            },
            type: 'post',
            success: function (data) {
                var orders = data.data.orders;
                $('#orderNo').val(orders.orderNo),
                $('#status').val(orders.status)


            }
        });
    }
    $('#saveOrders').click(function(){
        alert($('#status').val());
        var data={
            orderNo:$('#orderNo').val(),
            status:$('#status').val(),
        }
        $.ajax({
            type: "get",
            dataType: "json",
            url: "/view/updateOrders",
            data: data,
            dataType: "json",
            success: function (data) {
                if (data.data) {
                    window.location.href = "/view/order?pageNumber=1&pageSize=10";
                }
            },

        });


    });
</script>

</body>
</html>
